Skip to content

fix: Normalize flags query param to array in TitleFlags#4002

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gazebo-1802-flags-typeerror
Open

fix: Normalize flags query param to array in TitleFlags#4002
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gazebo-1802-flags-typeerror

Conversation

@sentry

@sentry sentry Bot commented Jun 16, 2026

Copy link
Copy Markdown

Description

This PR addresses GAZEBO-1802, a TypeError: b.forEach is not a function occurring in src/ui/FileViewer/ToggleHeader/Title/Title.tsx.

Code Example

Notable Changes

Root Cause:
The useLocationParams hook, which utilizes qs.parse, returns a plain string for single-value query parameters (e.g., ?flags=some-flag-name) instead of an array. This string then overwrites the default empty array for params.flags. When params?.flags?.forEach() is subsequently called, it attempts to invoke forEach on a string, leading to the TypeError.

Solution:

  1. Type Update: Modified the LocationParams type to correctly reflect that params.flags can be either a string or string[] as returned by qs.parse.
  2. Parameter Normalization: Introduced a flagsParam variable within the TitleFlags component. This variable uses Array.isArray() to ensure that params.flags is always coerced into an array, regardless of whether qs.parse returned a string or an array.
  3. Safe Usage: Updated the useState initialization for selectedFlags and the .forEach() call to use the newly normalized flagsParam. This guarantees that .forEach() is always called on an array, preventing the TypeError.

This fix is localized to the TitleFlags component, ensuring that the forEach operation is always performed on a valid array without introducing global changes to useLocationParams.

Screenshots

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes GAZEBO-1802

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1841 1 1840 2
View the top 1 failed test(s) by shortest run time
src/shared/GlobalTopBanners/TrialBanner/TrialBanner.test.tsx > TrialBanner > owner does not belong to org > renders nothing
Stack Traces | 0.0321s run time
AssertionError: expected 1 to be +0 // Object.is equality

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>

- Expected
+ Received

- 0
+ 1

 ❯ .../GlobalTopBanners/TrialBanner/TrialBanner.test.tsx:253:60
 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@.../dom/dist/config.js:47:12
 ❯ checkCallback node_modules/@.../dom/dist/wait-for.js:124:77
 ❯ node_modules/@.../dom/dist/wait-for.js:82:9

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 58 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.88MB 41 bytes (0.0%) ⬆️
gazebo-production-esm 5.96MB 17 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: gazebo-production-system

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/RawFileViewer-legacy.*.js 41 bytes 127.4kB 0.03%

Files in assets/RawFileViewer-legacy.*.js:

  • ./src/ui/FileViewer/ToggleHeader/Title/Title.tsx → Total Size: 3.88kB
view changes for bundle: gazebo-production-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/RawFileViewer.*.js 17 bytes 127.16kB 0.01%

Files in assets/RawFileViewer.*.js:

  • ./src/ui/FileViewer/ToggleHeader/Title/Title.tsx → Total Size: 3.84kB

@codecov-public-qa

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1841 1 1840 2
View the full list of 1 ❄️ flaky tests
src/shared/GlobalTopBanners/TrialBanner/TrialBanner.test.tsx > TrialBanner > owner does not belong to org > renders nothing

Flake rate in main: 8.33% (Passed 33 times, Failed 3 times)

Stack Traces | 0.0321s run time
AssertionError: expected 1 to be +0 // Object.is equality

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>

- Expected
+ Received

- 0
+ 1

 ❯ .../GlobalTopBanners/TrialBanner/TrialBanner.test.tsx:253:60runWithExpensiveErrorDiagnosticsDisabled node_modules/@.../dom/dist/config.js:47:12checkCallback node_modules/@.../dom/dist/wait-for.js:124:77node_modules/@.../dom/dist/wait-for.js:82:9

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@codecov-releaser

Copy link
Copy Markdown
Collaborator

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
91677f6 Tue, 16 Jun 2026 08:14:28 GMT Cloud Enterprise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant